/*
 * Jp_NouvelUtilisateur.java
 *
 * Created on 6 avril 2008, 15:21
 */

package gui;

import IBO.IEmploye;
import IBO.IZoneGeographique;
import IUSECASE.IUC_Factory;
import boerrors.CodePostalInexistantException;
import java.rmi.RemoteException;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;

/**
 *
 * @author  olivierm
 */
public class Jp_NouvelUtilisateur extends javax.swing.JPanel implements IXchangeCP{
    
    Frm_Application _parent = null;
    private String[] _codePostal = null;
    private Boolean[] _role = null;
    private Vector<IZoneGeographique> _zones = null;
    private DefaultComboBoxModel _modele = new DefaultComboBoxModel();
    
    private void resetFields(){
        jtxt_Nom.setText("");
        jtxt_Prenom.setText("");
        jtxt_Fonction.setText("");
        jtxt_Email.setText("");
        jtxt_Telephone.setText("");
        jtxt_Rue.setText("");
        jtxt_Numero.setText("");
        jtxt_CodePostal.setText("");
        jtxt_IdZone.setText("");
        jtxt_Commune.setText("");
        jtxt_Matricule.setText("");
        jtxt_Password.setText("");
        jchkb_GClients.setSelected(false);
        jchkb_GDirection.setSelected(false);
        jchkb_GInterventions.setSelected(false);
        jchkb_GOnSite.setSelected(false);
        jchkb_GPlanning.setSelected(false);
        jchkb_GSystem.setSelected(false);
        jcbb_Zone.setEnabled(false);
    }
    
    private boolean checkInformations(){
        if (jtxt_Nom.getText().compareTo("") == 0){
            return false;
        }
       if (jtxt_Prenom.getText().compareTo("") == 0){
            return false;
        }
        if (jtxt_Email.getText().compareTo("") == 0){
            return false;
        }
        if (jtxt_Telephone.getText().compareTo("") == 0){
            return false;
        }
        if (jtxt_Fonction.getText().compareTo("") == 0){
            return false;
        }
        if (jtxt_Rue.getText().compareTo("") == 0){
            return false;
        }
        if (jtxt_Numero.getText().compareTo("") == 0){
            return false;
        }
        if (jtxt_CodePostal.getText().compareTo("") == 0){
            return false;
        }
        if (jtxt_Commune.getText().compareTo("") == 0){
            return false;
        }
        if (jtxt_Matricule.getText().compareTo("") == 0){
            return false;
        }
        if (jtxt_Password.getText().compareTo("") == 0){
            return false;
        }
        return true;
    }
    
    public void initComponents2(Frm_Application parent){
            this._parent = parent;
    }
    
    public void setZones(){
        try {
            this._modele.removeAllElements();
            this._zones = this._parent.getFactoryRmi().getGestionEmployes().listerZone();
            for (int i = 0; i < this._zones.size(); i++) {
                this._modele.addElement(this._zones.get(i).getIdZone() + " - " + this._zones.get(i).getLibelleZone());
            }
        } catch (RemoteException ex) {
            Logger.getLogger(Jp_NouvelUtilisateur.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    /** Creates new form Jp_NouvelUtilisateur */
    public Jp_NouvelUtilisateur() {
        initComponents();
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel7 = new javax.swing.JPanel();
        jLabel11 = new javax.swing.JLabel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jXTitledPanel1 = new org.jdesktop.swingx.JXTitledPanel();
        jPanel1 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jtxt_Numero = new javax.swing.JTextField();
        jtxt_Rue = new javax.swing.JTextField();
        jtxt_Telephone = new javax.swing.JTextField();
        jtxt_Email = new javax.swing.JTextField();
        jtxt_Fonction = new javax.swing.JTextField();
        jtxt_Prenom = new javax.swing.JTextField();
        jtxt_Nom = new javax.swing.JTextField();
        jPanel5 = new javax.swing.JPanel();
        jLabel10 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jtxt_CodePostal = new javax.swing.JTextField();
        jtxt_Commune = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        jtxt_IdZone = new javax.swing.JTextField();
        jbtn_Rechercher = new javax.swing.JButton();
        jXTitledPanel2 = new org.jdesktop.swingx.JXTitledPanel();
        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jtxt_Matricule = new javax.swing.JTextField();
        jPanel3 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jtxt_Password = new javax.swing.JPasswordField();
        jPanel4 = new javax.swing.JPanel();
        jchkb_GClients = new javax.swing.JCheckBox();
        jchkb_GInterventions = new javax.swing.JCheckBox();
        jchkb_GPlanning = new javax.swing.JCheckBox();
        jchkb_GDirection = new javax.swing.JCheckBox();
        jchkb_GSystem = new javax.swing.JCheckBox();
        jchkb_GOnSite = new javax.swing.JCheckBox();
        jLabel14 = new javax.swing.JLabel();
        jcbb_Zone = new javax.swing.JComboBox();
        jbtn_Annuler = new javax.swing.JButton();
        jbtn_Creer = new javax.swing.JButton();

        jPanel7.setBackground(new java.awt.Color(0, 102, 153));
        jPanel7.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel11.setFont(new java.awt.Font("Tahoma", 3, 14));
        jLabel11.setForeground(new java.awt.Color(255, 255, 255));
        jLabel11.setText("Création d'un nouvel utilisateur");

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel11)
                .addContainerGap(208, Short.MAX_VALUE))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel11)
                .addContainerGap())
        );

        jXTitledPanel1.setTitle("Données de l'employé");

        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel3.setText("Nom:");

        jLabel4.setText("Prénom:");

        jLabel5.setText("Fonction:");

        jLabel6.setText("Email:");

        jLabel7.setText("Téléphone:");

        jLabel8.setText("Rue:");

        jLabel9.setText("Numéro:");

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Localité"));

        jLabel10.setText("Commune:");

        jLabel12.setText("Code Postal:");

        jtxt_CodePostal.setEditable(false);

        jtxt_Commune.setEditable(false);

        jLabel13.setText("Zone:");

        jtxt_IdZone.setEditable(false);

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel12)
                    .addComponent(jLabel10))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jtxt_Commune, javax.swing.GroupLayout.DEFAULT_SIZE, 195, Short.MAX_VALUE)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(jtxt_CodePostal, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel13)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtxt_IdZone, javax.swing.GroupLayout.DEFAULT_SIZE, 67, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(jLabel13)
                    .addComponent(jtxt_CodePostal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jtxt_IdZone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(jtxt_Commune, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jbtn_Rechercher.setText("Rechercher");
        jbtn_Rechercher.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_RechercherActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbtn_Rechercher))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel5)
                            .addComponent(jLabel9)
                            .addComponent(jLabel8)
                            .addComponent(jLabel7)
                            .addComponent(jLabel6)
                            .addComponent(jLabel4)
                            .addComponent(jLabel3))
                        .addGap(11, 11, 11)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jtxt_Numero, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 310, Short.MAX_VALUE)
                            .addComponent(jtxt_Rue, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 310, Short.MAX_VALUE)
                            .addComponent(jtxt_Telephone, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 310, Short.MAX_VALUE)
                            .addComponent(jtxt_Email, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 310, Short.MAX_VALUE)
                            .addComponent(jtxt_Fonction, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 310, Short.MAX_VALUE)
                            .addComponent(jtxt_Prenom, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 310, Short.MAX_VALUE)
                            .addComponent(jtxt_Nom, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 310, Short.MAX_VALUE))))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jtxt_Nom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jtxt_Prenom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jtxt_Fonction, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jtxt_Email, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jtxt_Telephone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(jtxt_Rue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(jtxt_Numero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbtn_Rechercher, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(15, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jXTitledPanel1Layout = new javax.swing.GroupLayout(jXTitledPanel1.getContentContainer());
        jXTitledPanel1.getContentContainer().setLayout(jXTitledPanel1Layout);
        jXTitledPanel1Layout.setHorizontalGroup(
            jXTitledPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jXTitledPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        jXTitledPanel1Layout.setVerticalGroup(
            jXTitledPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jXTitledPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Détails", jXTitledPanel1);

        jXTitledPanel2.setTitle(" Données et droits du compte utilisateur");

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Définition du matricule"));

        jLabel1.setText("Matricule:");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtxt_Matricule, javax.swing.GroupLayout.DEFAULT_SIZE, 316, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jtxt_Matricule, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Définition du mot de passe"));

        jLabel2.setText("Mot de passe:");

        jtxt_Password.setText("jPasswordField1");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addGap(18, 18, 18)
                .addComponent(jtxt_Password, javax.swing.GroupLayout.DEFAULT_SIZE, 281, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jtxt_Password, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Définition des droits"));

        jchkb_GClients.setText("Gestionnaire de clients");

        jchkb_GInterventions.setText("Gestionnaire d'interventions");

        jchkb_GPlanning.setText("Gestionnaire du planning");

        jchkb_GDirection.setText("Gestionnaire de direction");

        jchkb_GSystem.setText("Gestionnaire du système");

        jchkb_GOnSite.setText("Gestionnaire OnSite");
        jchkb_GOnSite.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jchkb_GOnSiteStateChanged(evt);
            }
        });

        jLabel14.setText("Zone:");

        jcbb_Zone.setModel(_modele);
        jcbb_Zone.setEnabled(false);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jchkb_GPlanning)
                    .addComponent(jchkb_GDirection)
                    .addComponent(jchkb_GSystem)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jchkb_GClients)
                            .addComponent(jchkb_GInterventions))
                        .addGap(23, 23, 23)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addGap(21, 21, 21)
                                .addComponent(jLabel14)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jcbb_Zone, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addComponent(jchkb_GOnSite))))
                .addContainerGap(78, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jchkb_GClients)
                    .addComponent(jchkb_GOnSite))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jchkb_GInterventions)
                    .addComponent(jLabel14)
                    .addComponent(jcbb_Zone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jchkb_GPlanning)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jchkb_GDirection)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jchkb_GSystem)
                .addContainerGap(15, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jXTitledPanel2Layout = new javax.swing.GroupLayout(jXTitledPanel2.getContentContainer());
        jXTitledPanel2.getContentContainer().setLayout(jXTitledPanel2Layout);
        jXTitledPanel2Layout.setHorizontalGroup(
            jXTitledPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jXTitledPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jXTitledPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jXTitledPanel2Layout.setVerticalGroup(
            jXTitledPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jXTitledPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Profil", jXTitledPanel2);

        jbtn_Annuler.setText("Annuler");
        jbtn_Annuler.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_AnnulerActionPerformed(evt);
            }
        });

        jbtn_Creer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/tick.png"))); // NOI18N
        jbtn_Creer.setText("Créer");
        jbtn_Creer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_CreerActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addComponent(jTabbedPane1))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(274, Short.MAX_VALUE)
                .addComponent(jbtn_Creer)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbtn_Annuler)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 371, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jbtn_Annuler)
                    .addComponent(jbtn_Creer))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jbtn_AnnulerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_AnnulerActionPerformed
        
        resetFields();
        this.setVisible(false);
        
}//GEN-LAST:event_jbtn_AnnulerActionPerformed

    private void jbtn_CreerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_CreerActionPerformed

        if (jchkb_GOnSite.isSelected()) {
            if (checkInformations()){
                creerTechnicien();
                resetFields();
                this.setVisible(false);
            }else{
                JOptionPane.showMessageDialog(this, "Veuillez remplir compléter toutes les informations","Information(s) manquante(s).", JOptionPane.WARNING_MESSAGE );
            }
        }else{
            if (checkInformations()){
                creerEmploye(); 
                resetFields();
                this.setVisible(false);                
            }else{
                JOptionPane.showMessageDialog(this, "Veuillez remplir compléter toutes les informations","Information(s) manquante(s).", JOptionPane.WARNING_MESSAGE );
            }

        }

        
    }//GEN-LAST:event_jbtn_CreerActionPerformed

    private void jbtn_RechercherActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_RechercherActionPerformed

        Jd_ListeCodePostaux objCp = new Jd_ListeCodePostaux(this._parent, true);
        objCp.initComponents2(this._parent, this);
        objCp.setVisible(true);
        
    }//GEN-LAST:event_jbtn_RechercherActionPerformed

    private void jchkb_GOnSiteStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jchkb_GOnSiteStateChanged

        if (jchkb_GOnSite.isSelected()) {
            jcbb_Zone.setEnabled(true);
        }else{
            jcbb_Zone.setEnabled(false);
        }
        
    }//GEN-LAST:event_jchkb_GOnSiteStateChanged
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JTabbedPane jTabbedPane1;
    private org.jdesktop.swingx.JXTitledPanel jXTitledPanel1;
    private org.jdesktop.swingx.JXTitledPanel jXTitledPanel2;
    private javax.swing.JButton jbtn_Annuler;
    private javax.swing.JButton jbtn_Creer;
    private javax.swing.JButton jbtn_Rechercher;
    private javax.swing.JComboBox jcbb_Zone;
    private javax.swing.JCheckBox jchkb_GClients;
    private javax.swing.JCheckBox jchkb_GDirection;
    private javax.swing.JCheckBox jchkb_GInterventions;
    private javax.swing.JCheckBox jchkb_GOnSite;
    private javax.swing.JCheckBox jchkb_GPlanning;
    private javax.swing.JCheckBox jchkb_GSystem;
    private javax.swing.JTextField jtxt_CodePostal;
    private javax.swing.JTextField jtxt_Commune;
    private javax.swing.JTextField jtxt_Email;
    private javax.swing.JTextField jtxt_Fonction;
    private javax.swing.JTextField jtxt_IdZone;
    private javax.swing.JTextField jtxt_Matricule;
    private javax.swing.JTextField jtxt_Nom;
    private javax.swing.JTextField jtxt_Numero;
    private javax.swing.JPasswordField jtxt_Password;
    private javax.swing.JTextField jtxt_Prenom;
    private javax.swing.JTextField jtxt_Rue;
    private javax.swing.JTextField jtxt_Telephone;
    // End of variables declaration//GEN-END:variables

    public void setCodePostal(String[] codePostal) {
        this._codePostal = codePostal;
        jtxt_Commune.setText(this._codePostal[2]);
        jtxt_CodePostal.setText(this._codePostal[1]);
        jtxt_IdZone.setText(this._codePostal[4]);        
    }
    
    private void creerTechnicien(){
        try {
            this._role = new Boolean[6];
            this._role[0] = jchkb_GClients.isSelected();
            this._role[1] = jchkb_GDirection.isSelected();
            this._role[2] = jchkb_GInterventions.isSelected();
            this._role[3] = jchkb_GOnSite.isSelected();
            this._role[4] = jchkb_GPlanning.isSelected();
            this._role[5] = jchkb_GSystem.isSelected();
            
            IUC_Factory factory = this._parent.getFactoryRmi();
            IZoneGeographique zone = this._zones.elementAt(jcbb_Zone.getSelectedIndex());
            factory.getGestionEmployes().creerTechnicien(Integer.parseInt(jtxt_Matricule.getText()), jtxt_Nom.getText(), jtxt_Prenom.getText(), jtxt_Rue.getText(), jtxt_Numero.getText(), this._codePostal, jtxt_Telephone.getText(), jtxt_Email.getText(), this._role, jtxt_Fonction.getText(), String.valueOf(jtxt_Password.getPassword()), zone);
            JOptionPane.showMessageDialog(this, "Nouveau technicien créé.","Opération de création réussie", JOptionPane.INFORMATION_MESSAGE );
            this.setVisible(false);        
        } catch (RemoteException ex) {
            JOptionPane.showMessageDialog(this, "Nouveau technicien non créé.","Opération de création en échec.", JOptionPane.ERROR_MESSAGE );
            Logger.getLogger(Jp_NouvelUtilisateur.class.getName()).log(Level.SEVERE, null, ex);
        }        
    }
    
    private void creerEmploye(){
        try {
            this._role = new Boolean[6];
            this._role[0] = jchkb_GClients.isSelected();
            this._role[1] = jchkb_GDirection.isSelected();
            this._role[2] = jchkb_GInterventions.isSelected();
            this._role[3] = jchkb_GOnSite.isSelected();
            this._role[4] = jchkb_GPlanning.isSelected();
            this._role[5] = jchkb_GSystem.isSelected();
            
            IUC_Factory factory = this._parent.getFactoryRmi();
            factory.getGestionEmployes().creerEmploye(Integer.parseInt(jtxt_Matricule.getText()), jtxt_Nom.getText(), jtxt_Prenom.getText(), jtxt_Rue.getText(), jtxt_Numero.getText(), this._codePostal, jtxt_Telephone.getText(), jtxt_Email.getText(), this._role, jtxt_Fonction.getText(), String.valueOf(jtxt_Password.getPassword()));
            JOptionPane.showMessageDialog(this, "Nouvel utilisateur/employé créé.","Opération de création réussie", JOptionPane.INFORMATION_MESSAGE );
            this.setVisible(false);        
        } catch (RemoteException ex) {
            JOptionPane.showMessageDialog(this, "Nouvel utilisateur/employé non créé.","Opération de création en échec.", JOptionPane.ERROR_MESSAGE );
            Logger.getLogger(Jp_NouvelUtilisateur.class.getName()).log(Level.SEVERE, null, ex);
        }        
    }
    
}
